var multer  = require('multer')

var storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, './public/uploads')
  },
  filename: function (req, file, cb) {
    let imgArr = file.mimetype.split('/');
    let extname = imgArr[imgArr.length-1]
    cb(null, file.fieldname + '-' + Date.now()+"."+ extname)
  }
})
 
var upload = multer({ storage: storage })
module.exports = upload